#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START dracut
# depends: cross-pkg-config
# depends: kmod

rm -rf build/dracut
cp -a dracut build/
cd build/dracut
# Thanks God dracut does NOT use autocrap
env \
	CC="${TARGET}-gcc" \
	PKG_CONFIG="${TARGET}-pkg-config" \
./configure \
	--prefix="$prefix" \
	--libdir="$prefix/lib" \
	--localstatedir=/var \
	--sysconfdir="$sysconfdir" \
	--disable-documentation \
	--systemdsystemunitdir=$prefix/lib/systemd/system \
	${NIL}

env \
	CC="${TARGET}-gcc" \
	PKG_CONFIG="${TARGET}-pkg-config" \
make -j${JOBS} \
	all install \
	DESTDIR=`pwd`/inst

# XXX: make install fails to overwrite existing files, hence install
# to an empty directory and copy to the $stage with tar

tar -c -f - -C inst . | tar -x -v -f - -C "$stage"
cd ../..
rm -rf build/dracut

# RECIPE END dracut
